<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      label-width="80px"
    >
      <el-form-item label="月份" prop="createYearMonth">
        <el-date-picker
          v-model="queryParams.createYearMonth"
          type="month"
          placeholder="请选择月份"
          value-format="YYYY-MM"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
      </el-form-item>
    </el-form>
    <el-table :data="tableData" show-summary v-loading="loading" border>
      <el-table-column label="区域" prop="regionName" />
      <el-table-column label="店面" prop="storeName" />
      <el-table-column label="加盟商" prop="franchiseeName" />
      <el-table-column label="经纪人" prop="askUser" />
      <el-table-column label="租赁业绩" prop="payPrice" />
    </el-table>
  </div>
</template>
<script setup name="LeaseStatistics">
import { ref } from "vue";
import { leaseStatistics } from "@/api/leaseReport";
import { onMounted } from "vue";
const queryParams = ref({
  createYearMonth: "",
});
const tableData = ref([]);
const loading = ref(false);
const queryRef = ref(null);
const handleQuery = () => {
  getList();
};

function getList() {
  loading.value = true;
  leaseStatistics(queryParams.value).then((res) => {
    tableData.value = res.data;
    loading.value = false;
  });
}
onMounted(() => {
  const curMonth = new Date().getMonth() + 1;
  const nowYearMonth =
    new Date().getFullYear() +
    "-" +
    (curMonth < 10 ? "0" + curMonth : curMonth);
  queryParams.value.createYearMonth = nowYearMonth;
  getList();
});
</script>
